<template>
  <div class="App" >
    <h1 :style="{ opacity }">React难吗？</h1>
    <button @click="pause">不难吗？</button>
  </div>
</template>

<script>
export default {
  name: "App",
  data() {
    return {
      opacity: 1,
      ontime: null,
    };
  },
  methods: {
    pause() {
      this.$destroy();
    },
  },
  mounted() {
    this.setInt = setInterval(() => {
      console.log(111);
      this.opacity -= 0.05;
      if (this.opacity < 0) {
        this.opacity = 1;
      }
    }, 100);
  },
  beforeDestroy() {
    clearInterval(this.setInt);
  },
};
</script>
